package cn.tedu.eb_film.controller;

import cn.tedu.eb_film.pojo.dto.CsRevocationRegulationAddNewDTO;
import cn.tedu.eb_film.pojo.dto.CsRevocationRegulationUpdateDTO;
import cn.tedu.eb_film.pojo.dto.CsTDCSAddNewDTO;
import cn.tedu.eb_film.pojo.dto.CsTDCSUpdateDTO;
import cn.tedu.eb_film.pojo.vo.CsRevocationRegulationListItemVO;
import cn.tedu.eb_film.pojo.vo.CsRevocationRegulationStandardVO;
import cn.tedu.eb_film.pojo.vo.CsTDCSListItemVO;
import cn.tedu.eb_film.pojo.vo.CsTDCSStandardVO;
import cn.tedu.eb_film.service.CsRevocationRegulationService;
import cn.tedu.eb_film.service.CsTDCSService;
import cn.tedu.eb_film.utils.JsonResult;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.hibernate.validator.constraints.Range;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**
 * 3d眼镜收费规则相关请求的控制器类
 *
 * @author @CJ
 * @version 0.0.1
 */

@Api(tags = "3d眼镜收费规则规制管理模块")
@Slf4j
@RestController
@RequestMapping("/cstdcs")
@Validated
public class CsTDCSController {

    @Autowired
    private CsTDCSService CsTDCSService;
    public CsTDCSController(){
        log.debug("创建控制器类对象：CsTDCSController");
    }

    // http://localhost:8888/employees/add-new
    @PostMapping("/add-new")
    @ApiOperation("添加3d眼镜收费规则规制")
    @ApiOperationSupport(order = 100)
    public JsonResult<Void> addNew(@Validated CsTDCSAddNewDTO addNewDTO){
        log.debug("开始处理【添加3d眼镜收费规则规制】的请求，参数：{}",addNewDTO);
        CsTDCSService.addNew(addNewDTO);
        return JsonResult.ok();
    }

    @PostMapping("/{id:[0-9]+}/delete")
    @ApiOperation("删除3d眼镜收费规则规制")
    @ApiOperationSupport(order = 200)
    @ApiImplicitParam(name = "id", value = "3d眼镜收费规则规制ID", required = true, dataType = "long")
    public JsonResult<Void> delete(@PathVariable@Range(min = 1,message = "请提交有效的id")Integer id){
        CsTDCSService.deleteById(id);
        return JsonResult.ok();
    }

    @PostMapping("/update")
    @ApiOperation("修改3d眼镜收费规制")
    @ApiOperationSupport(order = 300)
    @ApiImplicitParam(name = "id", value = "3d眼镜收费规制ID", required = true, dataType = "long")
    public JsonResult<Void> updateInfoById(CsTDCSUpdateDTO csTDCSUpdateDTO){
        log.debug("开始处理【修改3d眼镜收费规则详情】的请求,新数据：{}",csTDCSUpdateDTO);
        CsTDCSService.update(csTDCSUpdateDTO);
        return JsonResult.ok();
    }

    @GetMapping("/{id:[0-9]+}")
    @ApiOperation("根据id查询3d眼镜收费规则")
    @ApiOperationSupport(order = 400)
    @ApiImplicitParam(name = "id", value = "3d眼镜收费规则ID", required = true, dataType = "int")
    public JsonResult<CsTDCSStandardVO> getStandardById(@PathVariable @Range(min = 1, message = "请提交有效的ID值！") Integer id){
        log.debug("开始处理【根据ID查询3d眼镜收费规则详情】的请求，参数：{}", id);
        CsTDCSStandardVO standardById = CsTDCSService.getStandardVOById(id);
        return JsonResult.ok(standardById);
    }

    @GetMapping("")
    @ApiOperation("查询3d眼镜收费规则列表")
    @ApiOperationSupport(order = 410)
    public JsonResult<List<CsTDCSListItemVO>> list(){
        log.debug("开始处理【查询3d眼镜收费规则列表】的请求，无参数");
        List<CsTDCSListItemVO> list = CsTDCSService.list();
        return JsonResult.ok(list);
    }


}
